﻿using UnityEngine;
using System.Collections;


/*
枚举可用于创建相关常量的集合。在本视频中，您将学习如何在代码中声明和使用枚举
*/
public class EnumScript : MonoBehaviour 
{
    enum Direction {North, East, South, West}; //默认是int 类型，赋值， 0 ,1,2,3
    //enum Direction :short  {North=10, East, South, West}; //默认是int 类型，赋值， 0 ,1,2,3  声明类型为short ，且可以自定义赋值

    void Start () 
    {
        Direction myDirection;
        
        myDirection = Direction.North;
    }
    
    //通过枚举的使用快速获取反反向。
    Direction ReverseDirection (Direction dir)
    {
        if(dir == Direction.North)
            dir = Direction.South;
        else if(dir == Direction.South)
            dir = Direction.North;
        else if(dir == Direction.East)
            dir = Direction.West;
        else if(dir == Direction.West)
            dir = Direction.East;
        
        return dir;     
    }
}